/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.register.Controller;

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

class SpeedyEmaiSendl implements Runnable{
     Thread t;

    public SpeedyEmaiSendl(String name) {

        t=new Thread(this, name);
        t.start();
    


    }

    

    public void run() {

        String data[]=t.getName().split(" ");
        

       final String username = "vehiclehai@gmail.com";
		final String password = "vehiclehai318899";

		Properties props = new Properties();
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.starttls.enable", "true");
		props.put("mail.smtp.host", "smtp.gmail.com");
		props.put("mail.smtp.port", "587");

		Session session = Session.getInstance(props,
		  new javax.mail.Authenticator() {
			protected PasswordAuthentication getPasswordAuthentication() {
				return new PasswordAuthentication(username, password);
			}
		  });

		try {

			Message message = new MimeMessage(session);
			message.setFrom(new InternetAddress("vehiclehai@gmail.com"));
			message.setRecipients(Message.RecipientType.TO,
				InternetAddress.parse(data[3]));
			message.setSubject("VehicleHai.com");
			//message.setText(data[0]+" "+data[1]+" Your Activation Link is : \nhttp://localhost:8084/Auto7.1/XSdsfbweybfjefsisanasjdhashduiashdasbhwuewqiourioefjnfjansfnsajasdsadjsadjasdjsaidjsadsjdsadhduawiduaduaudusadsaudHHJHBSHSBhbhbdshfbd.jsp?code="+data[2]+"");


                         String firstName=data[0];
                        String lastName=data[1];

                         String one="<div style=\"border-style: groove; height:auto; width: 706px; position: absolute;left: 177px; background-image: url('http://t2.gstatic.com/images?q=tbn:ANd9GcTGzFKvBTTPo4WIis3hiZ4D0PAdtUexzY4v7OgZ_JKNHQxvxhVmXg')\">";
                        String two=" <img src=\"https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xap1/t1.0-9/10415593_649618058458679_2576350660267820106_n.jpg\" style=\"width:706px;\" align=\"center\"><br><br><hr><p><font color=\"white\">Dear<b> "+firstName.substring(0,1).toUpperCase()+firstName.substring(1)+" "+lastName.substring(0,1).toUpperCase()+lastName.substring(1)+"</b>,<br><br><br> Thank You For Registring With <a href=\"www.vehiclehai.com\"> www.VehicleHai.com</a><br><br>";
                        String four=" Your Account Is Successfully Created With <a href=\"www.vehiclehai.com\"> www.VehicleHai.com</a><br><br>Your Account Is Not Activted Click On Follwing Button Inorder To Activate Your <a href=\"www.vehiclehai.com\"> www.VehicleHai.com</a> Account : <br><br><br><b><a href=\"http://localhost:8084/Auto7.1/XSdsfbweybfjefsisanasjdhashduiashdasbhwuewqiourioefjnfjansfnsajasdsadjsadjasdjsaidjsadsjdsadhduawiduaduaudusadsaudHHJHBSHSBhbhbdshfbd.jsp?code="+data[2]+"\"><img src='https://scontent-a-cdg.xx.fbcdn.net/hphotos-xfp1/t1.0-9/10405408_649603845126767_1454075252364928440_n.jpg'/></a><br>";
                        String five=" <br><br>Or Cheack Your SMS At <b>"+data[4]+"</b><br><br><br>Ragistrasion Is Done Vie An IP Address:"+data[5]+"</font></p><hr><p><font color=\"white\"><p>Contact:</p>Toll Free:18003821,18008345<br><br><img src='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRBhtapKbORn852vF_NlSHQ-evGwSQ2r1zwF6VIhp932__pvCr-35_wBtMI' style=\"width:45px; height:45px;\"/>...<img src='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQWlX7wCvhSVzEHjzUerot4gsrxn21MDLUwQHBFOhhIZglbXZf1jSMYyJkr' style=\"width:45px; height:45px;\"/>...<img src='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSzAndtzwGwgg5Whf9pe85eSRrGtUiM-7tPyBu-qrXF63Ph3gqlRiwbcG8' style=\"width:95px; height:45px;\"/><br><br>Best Regards<br>www.VehicleHai.com Team</font></p><hr><br><img src=\"https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xap1/t1.0-9/10415593_649618058458679_2576350660267820106_n.jpg\" style=\"width:706px;\" align=\"center\"></div></head>";
                        String mail=one+two+four+five;


                              message.setContent(mail,"text/html");




			Transport.send(message);

			System.out.println("Done");

		} catch (MessagingException e) {

		}
    }

    
    
}